# Makefile

CC = g++
LD = g++
CFLAGS = -Wall -O2 -D NDEBUG
LDFLAGS = -Wall -lpthread -lm
RM = /bin/rm -f
CLASS_OBJS = ray.o vector.o utils.o threads.o
OBJS = $(CLASS_OBJS) main.o 
PROG = ray

build: $(PROG)

#overwrite CFLAGS
debug: CFLAGS = -Wall -ggdb -D DEBUG
debug: build

$(PROG): $(OBJS)
	$(LD) $(LDFLAGS) $^ -o $@

$(OBJS): %.o: %.cpp 
	$(CC) $(CFLAGS) -c $< -o $@

$(CLASS_OBJS): %.o: %.cpp %.h

ray.o utils.o threads.o: raytypes.h

threads.o utils.o: externs.h

clean:
	$(RM) $(PROG) $(OBJS)

rebuild: clean build

redebug: clean debug
